<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Pragma" content="no-cache" />
		<title>通讯录</title>
		<%@ include file="/user_comm.jsp"%>
		<!--  
<link rel="stylesheet"	href="http://a.tbcdn.cn/apps/sell/1.0/publish_detail_ke.css?t=20110128editor.css" />
 -->

<link href="<%=request.getContextPath()%>/css/prop.css" type="text/css" rel="stylesheet"/>

		<!-- script start -->
		<script language="JavaScript">
	var addflag=true;//操作标识
	var selGroupId=0; //当前所选联系组ID
	var selMemberId='';//当前所选联系人ID
	var oldGrpName; //联系组修改前的旧组名
	var contactList; //所有联系人数据
	$(document).ready(function(){
		loadContact();
		loadMember(0);//显示所有
	});
	
	function loadContact(){
		var params = {};
		$.ajax({type: "POST",
		       url: "ajaxContact_loadContact.do",
		       data: params,
		       async: false,   
		       success: function(result){
				contactList = result.contactList;
				var groupHtml="";
				for(var i=0;i<contactList.length;i++){
					var group=contactList[i].group;
					groupHtml +="<a href='#' onclick=\"loadMember("+group.id+");\">"+group.groupName+"("+group.count+")</a><br/>";
				}
				$("#spanGroups").html(groupHtml);
			  }
			},"json");
	}
	
	//通过组ID取组成员信息
	function getGroupMembers(groupId){
		for(var i=0;i<contactList.length;i++){
			var group=contactList[i].group;
			if(group.id==groupId){
				return contactList[i].memberList;
			}
		}
		return;
	}
	
	//加载联系人列表
	function loadMember(groupId) {
	   selMemberId='';
	   $d("div_memberlist").style.display="block";
   	   $d("div_editgroup").style.display="none";
   	   $d("div_editmember").style.display="none";
   	   $d("div_viewmember").style.display="none";
   	   
   	   
   	   $d("div_toolbar1").style.display="block";
   	   $d("div_toolbar2").style.display="block";
   	   $d("div_goBack1").style.display="none";
   	   $d("div_goBack2").style.display="none";
   	   
   	    selGroupId=groupId;
		if(parseInt(selGroupId)<=0){ //0所有,-1本公司,-2未分组 时隐藏 div_group 
			$d("a_editGroup").style.display="none";
			$d("a_deleteGroup").style.display="none";
		}else{
			$d("a_editGroup").style.display="block";
			$d("a_deleteGroup").style.display="block";
		}
		
		$d("a_editMember").style.display="none";
   	    if(selGroupId=='-1'){//公司
			$d("a_delMember").style.display="none";
		}else{
			$d("a_delMember").style.display="block";
		}
   	   
		var memberList = getGroupMembers(groupId);
		if(memberList.length==0){   
		    $("#tb_memberList").html("<tr><td><span class='orange1 ml5'>没有联系人在分组中</span></td></tr>");
		    return;
		}
				
		var result="<thead>"
		result += "<tr>";
		result += "<th class='title' align='center'><input id='chkAll' name='chkAll' type='checkbox' onclick=\"ChkAllClick('chkSon','chkAll')\"></th>";
		result += "<th class='title'>账户代码</th>";
		result += "<th class='title'>账户名称</th>";
		result += "<th class='title'>姓名</th>";
		result += "<th class='title'>电话</th>";
		result += "<th class='title'>电子邮件</th>";
		result += "</tr>";
		result += "</thead>";
		result += "<tbody>";
		//这里的order[i]就相当于list中的order,起属性也是一一对应的   
		for(var j=0;j<memberList.length;j++) {   
		    result += "<tr>"; 
		    result += "<td align='center' width='20'><input id='"+memberList[j].id+"' name='chkSon' type='checkbox' value='"+memberList[j].id+"' onclick=\"ChkSonClick('chkSon','chkAll')\"></td>";
		    result += "<td onclick=\"viewMember("+memberList[j].id+",'"+memberList[j].flag+"')\"><a href='#'>"+memberList[j].relateUserid+"</a></td>";   
		    result += "<td>"+memberList[j].relateCompanyName+"</td>";
		    result += "<td>"+memberList[j].relateName+"</td>";
		    result += "<td>"+memberList[j].telephone+"</td>";
		    result += "<td>"+memberList[j].email+"</td>";
		    result += "</tr>";   
		} 
		result += "</tbody>";
		$("#tb_memberList").html(result);
	}
	
   function addGroup(){
	   $d("div_memberlist").style.display="none";
   	   $d("div_editgroup").style.display="block";
   	   $d("div_editmember").style.display="none";
   	   $d("div_viewmember").style.display="none";
   	   showGoback();
   	   addflag=true;
   	   selGroupId='0';
   	   initEditGroup();
   }
   
   function editGroup(){
   	   $d("div_memberlist").style.display="none";
   	   $d("div_editgroup").style.display="block";
   	   $d("div_editmember").style.display="none";
   	   $d("div_viewmember").style.display="none";
   	   showGoback();
   	   addflag=false;
   	   initEditGroup();
   }
   
   function delGroup(){
		$.prompt('是否彻底删除此联系组？ 仅存在此分组的联系人会移到"未分组"。',{
			submit: delGroupCallback,
			buttons:{Ok:true,Cancel:false}
		});
   }
   
   function delGroupCallback(v,m,f){
   		if(v==true){
	   		var params = { groupId:selGroupId };
	   		$.ajax({type: "POST",
			       url: "ajaxContact_delGroup.do",
			       data: params,
			       async: false,   
			       success: function(result){
					//alert(result.retmsg);
				  }
				},"json");
	   	   loadContact();
	   	   loadMember(0);
   	   }
   }
   
   function addMember(){
       $d("div_memberlist").style.display="none";
   	   $d("div_editgroup").style.display="none";
   	   $d("div_editmember").style.display="block";
   	   $d("div_viewmember").style.display="none";
   	   
   	   selMemberId='';
   	   showGoback();
   	   addflag=true;
   	   initEditMember();
   }
   
   function editMember(){
   	   $d("div_memberlist").style.display="none";
   	   $d("div_editgroup").style.display="none";
   	   $d("div_editmember").style.display="block";
   	   $d("div_viewmember").style.display="none";
   	   
   	   showGoback();
   	   addflag=false;
   	   initEditMember();
   }
   
   function viewMember(memberId,flag){
   	   $d("div_memberlist").style.display="none";
   	   $d("div_editgroup").style.display="none";
   	   $d("div_editmember").style.display="none";
   	   $d("a_editGroup").style.display="none";
	   $d("a_deleteGroup").style.display="none";
	   $d("div_viewmember").style.display="block";
			
   	   selMemberId=memberId;
   	   var params={};
   	   if(flag=='1'){//公司
   	   	  $d("a_editMember").style.display="none";
   	   	  params = {
				relateUserid:memberId
				};
   	   }else{
   	   	  $d("a_editMember").style.display="block";
   	   	  params = {
				memberId:memberId
				};
   	   }
	   $.ajax({type: "POST",
		       url: "ajaxContact_findMember.do",
		       data: params,
		       async: false,   
		       success: function(result){
				if(result.retcode=='0000'){
					var dto=result.memberInfoDto;
					spanCompanyId.innerHTML=dto.relateCompanyid;
					spanCompanyName.innerHTML=dto.relateCompanyName;
					spanUserid.innerHTML=dto.relateUserid;
					spanUsername.innerHTML=dto.relateName;
					spanEmail.innerHTML=dto.email;
					spanTelephone.innerHTML=dto.telephone;
					if(dto.flag=='2'){
						tr_memberInfo2.style.display="block";
						tr_memberInfo3.style.display="block";
						spanRemark.innerHTML=dto.remark;
					
						var grpNames='';
						var grpList=result.grpList;
						for(var i=0;i<grpList.length;i++){
							if(grpNames=='')
								grpNames=grpList[i].groupName;
							else
								grpNames=grpNames+'，' + grpList[i].groupName;
						}
						spanInGroups.innerHTML=grpNames;
						
					}else{
						tr_memberInfo2.style.display="none";
						tr_memberInfo3.style.display="none";
					}
				}else{
					alert("未找到联系人资料");
				}
			  }
		   },"json");
   }
   
   function delMember(){
   		var propTip="";
   		var selMemberIds = checkboxvalue("chkSon");
   		if(selMemberId =='' && selMemberIds==''){
   			alert("请选择要删除的联系人");
   			return;
   		}
   		
   		if(parseInt(selGroupId)<=0 || selMemberId !=''){
			propTip='是否彻底删除所选择的联系人？<br/><font color="gray">该操作将把联系人从所有组中删除。</font>';
		}else{
			propTip='确定将选中的联系人移出当前组？<br/><input id="chkDelflag" type="checkbox" /><font color="red">并从通讯录中彻底删除</font>';			
		}
		$.prompt(propTip,{
			submit: delMemberCallback,
			buttons:{Ok:true,Cancel:false}
		});
   }
   
   function delMemberCallback(v,m,f){
   		if(v==true){
		  var delflag='0'; //是否彻底删除
	   	  if(parseInt(selGroupId)<=0 || selMemberId !=''){
	   	      delflag='1';
	   	  }else{
	   	  	  if($('#chkDelflag').attr("checked")==true)
	   	  	  	delflag='1';
	   	  }
	   	  var params={};
	   	  if(selMemberId != ''){
	   	  	  params = {
						memberId:selMemberId,
						operFlag:delflag
						};
	   	  }else{
	   	  	  //删除确认
	   	  	  var selMemberIds = checkboxvalue("chkSon");
	      	  params = {
						groupId:selGroupId,
						memberId:selMemberIds,
						operFlag:delflag
						};
	   	  }
	   	  
	   	  $.ajax({type: "POST",
			       url: "ajaxContact_delMembers.do",
			       data: params,
			       async: false,   
			       success: function(result){
					alert(result.retmsg);
				  }
				},"json");
	   	   loadContact();
	   	   loadMember(selGroupId);
	   }
   }
   
   function showGoback(bShow){
   	  $d("div_toolbar1").style.display="none";
   	  $d("div_toolbar2").style.display="none";
   	  $d("div_goBack1").style.display="block";
   	  $d("div_goBack2").style.display="block";
   }
   
   function goBack(){
   	  loadMember(selGroupId);
   }
   
   //for editGroup start ===================================
   var checkGrpNameFlag=true;
   function checkGroupName(txtGroupName){
		var grpName=txtGroupName.value;
		if(grpName == ""){
			$d("groupNameError").innerHTML="请输入组名";
			return;
		}
		//判断编辑时组名是否更改了
		if(addflag==false && oldGrpName == grpName) return; //未更改组名
		var operFlag="edit";
		if(addflag==true)
			operFlag="add";
		var params = {
					groupName:grpName,
					operFlag:operFlag,
					groupId:selGroupId
					};
		$.ajax({type: "POST",
		       url: "ajaxContact_checkGrpNameExist.do",
		       data: params,
		       async: false,   
		       success: function(result){
				 if(result.retcode=="0000"){
				  	groupNameError.innerHTML="组名可用";
				 	checkGrpNameFlag=true;
				 }else{
				  	groupNameError.innerHTML="组名已存在";
				  	checkGrpNameFlag=false;
				 }
			  }
			},"json");
	}
	
	function initEditGroup(){
		//初始化listbox1
		//如果新增，listbox1为所有联系人成员，否则为不在该组的联系人成员
		var listbox1=$d("list1");
		var listbox2=$d("list2");
		listbox1.length=0;
		listbox2.length=0;
		$d("txtGroupName").value="";
		
		//初始化可选组下拉列表 myGroup
		var params = {};
		var myGroups=$d("myGroups");
		myGroups.options.length = 0;
		var count=0;
		for(var i=0;i<contactList.length;i++){
			var group=contactList[i].group;
			if(group.id != -1){
				myGroups.options[count] = new Option(group.groupName,group.id);
			    if(addflag==false && group.id==selGroupId){
			    	oldGrpName=group.groupName;
			    	$d("txtGroupName").value=oldGrpName;
			    }
			    count++;
		    }
		}
				
		//初始化可选联系人，已选联系人控件	
		if(addflag==true){//新增
			//下拉显示所有联系人
			fillListbox(listbox1,getGroupMembers(0));
		}else{//如果为修改
			//初始化listbox2
			fillListbox(listbox2,getGroupMembers(selGroupId));
			//置未分组下拉项为选中状态（下拉项最后一项为未分组）
			myGroups.options[myGroups.options.length-1].selected=true;
			
			//取未分组联系人到listbox1
			fillListbox(listbox1,getGroupMembers(-2));
			//设置未分组下拉项为选中
			
		}
		
		//编辑联系组控件属性绑定 
		//双击
	    $("#list1").dblclick(function(){
	        move(listbox1,listbox2);
	    });
	    $("#list2").dblclick(function(){
	        move(listbox2,listbox1);
	    });
	    //添加
	    $("#btnAdd").click(function(){
	        if(listbox1.selectedIndex>=0){
	            move(listbox1,listbox2);
	        }else{
	            alert("请选择联系人");
	        }
	    });
	    //移除
	    $("#btnRemove").click(function(){
	        if(listbox2.selectedIndex>=0){
	            move(listbox2,listbox1);
	        }else{
	            alert("请选择联系人");
	        }
	    });
	    //联系组下拉改变时
	    $("#myGroups").change(function(){
	        var gid=this.value;
			var memberList1 = getGroupMembers(gid);   
			listbox1.length=0;
			var index=0;
			for(var i=0;i<memberList1.length;i++) { 
				if(listbox2.options.length>0){
					var hasflag=false;
					for(var j=0;j<listbox2.options.length;j++){
						if(listbox2.options[j].value==memberList1[i].id){
							hasflag=true;
							break;
						}else{
						 	continue;
					    }
					}
					if(hasflag==false){
						listbox1.options[index] = new Option(memberList1[i].relateUserid,memberList1[i].id); 
						index++;
					}
				}else{
					listbox1.options[index] = new Option(memberList1[i].relateUserid,memberList1[i].id); 
					index++;
				}
			}
	    });
	}
	
	function saveGroup(){
		var grpName=$d("txtGroupName").value;
		if(grpName == ""){
			$d("groupNameError").innerHTML="请输入组名";
			alert("组名不能为空");
			return;
		}
		$d("groupNameError").innerHTML="请输入组名";
		if(checkGrpNameFlag==false){
			alert("组名重复，请尝试其它组名");
			return false;
		}else{
			//保存组
			var listbox2=$d("list2");
	        /*
	        var resultArr=[];
		    for(var i=0,len=listbox2.length;i<len;i++){
		        resultArr.push(listbox2.options[i].value);
		        alert(listbox2.options[i].value);
		    }
		    */
		    var resultArr='';
		    for(var i=0,len=listbox2.length;i<len;i++){
		        resultArr=resultArr+listbox2.options[i].value+",";
		    }
			params = {
					  groupId:selGroupId,
					  groupName:$d("txtGroupName").value,
					  selMembers:resultArr
					 };
			$.ajax({type: "POST",
			       url: "ajaxContact_saveGroup.do",
			       data: params,
			       async: false,   
			       success: function(result){
			         if(result.retcode='0000'){
				        loadContact();
						loadMember(result.groupId);
						alert(result.retmsg);
					 }else{
					 	alert(result.retmsg);
					 }
				  }
			},"json");
		}
		
		return true;
	}
   //for editGroup end =====================================
   
   //for editMember start ==================================
   function initEditMember(){
   		$d("userIdError").innerHTML="";
   		$d("companyIdError").innerHTML="";
   		$d("txtCompanyId").value="";
		$d("txtUserId").value="";
		$d("txtUsername").value="";
		$d("txtEmail").value="";
		$d("txtTelephone").value="";
		$d("txtRemark").value="";
				  	
		var params = {};
		var result = "";
		for(var i=0;i<contactList.length;i++) {
			var group=contactList[i].group;
			if(group.id>0){
			    result += "<input type='checkbox' name='chk_group' id='chk_group"+group.id+"' value='"+group.id+"'/>&nbsp;";
			    result += group.groupName;
			    result += "<br/>";
		    }
		}
		div_groups.innerHTML = result;
		//如果当前为新增操作且当前所选组不为空，则置当前所选组为选中状态
		if(selGroupId>0 && addflag==true)
			$d("chk_group"+selGroupId).checked=true;
		
		//如果是修改，初始化已经所在组为选中状态
		if(selMemberId >0){
		   var params = {
   	   	  			memberId:selMemberId
					};
		   $.ajax({type: "POST",
			       url: "ajaxContact_findMember.do",
			       data: params,
			       async: false,   
			       success: function(result){
					if(result.retcode=='0000'){
						var dto=result.memberInfoDto;
						$d("txtCompanyId").value=dto.relateCompanyid;
						$d("txtUserId").value=dto.relateUserid;
						$d("txtUsername").value=dto.relateName;
						$d("txtEmail").value=dto.email;
						$d("txtTelephone").value=dto.telephone;
						$d("txtRemark").value=dto.remark;
						var grpList=result.grpList;
						for(var i=0;i<grpList.length;i++){
							var chkbox=$d("chk_group"+grpList[i].id);
							if(chkbox != null)
							  chkbox.checked=true;
						}
					}else{
						alert("未找到联系人资料");
					}
				  }
			   },"json");
		}
	}
	
	var checkMemberFlag=true;//判断是否可用
	function checkUserId(txtUserId){
		var userIdVal=txtUserId.value;
		if(userIdVal==""){
			$d("userIdError").innerHTML="请输入账户代码";
			checkMemberFlag=false;
			return;
		}
		
		var companyIdVal=$d("txtCompanyId").value;
		if(companyIdVal==""){
			$d("companyIdError").innerHTML="请输入公司代码";
			checkMemberFlag=false;
			return;
		}
		var userIdStr=companyIdVal+"-"+userIdVal;
		var params = {
					userIdVal:userIdStr
					};
		$.ajax({type: "POST",
		       url: "ajaxUser_checkUserId.do",
		       data: params,
		       async: false,   
		       success: function(result){
				 if(result.userIdExist=="false"){
				  	userIdError.innerHTML="账户代码不存在";
				 	checkMemberFlag=false;
				 }else{
				 	userIdError.innerHTML="";
				  	checkMemberFlag=true;
				 }
			  }
			},"json");
	}
	
	function showCompanyName(txtCompanyId){
		var companyIdVal=txtCompanyId.value;
		if(companyIdVal==""){
			$d("companyIdError").innerHTML="请输入公司代码";
			checkMemberFlag=false;
			return;
		}
		
		//添加验证公司代码必须为正整数
		var params = {companyIdVal:companyIdVal};
		$.ajax({type: "POST",
		       url: "ajaxUser_findCompany.do",
		       data: params,
		       async: false,
		       success: function(result){
		         var companyInfo = result.companyInfo;
		         if(companyInfo!=null){
		         	companyIdError.innerHTML=companyInfo.companyName;
		         	checkMemberFlag=true;
		         }else{
					companyIdError.innerHTML="不存在的公司代码";
					checkMemberFlag=false;		         
		         }
			  }
			},"json");
	}
	
	function saveMember(){
		if(checkMemberFlag==false){
			alert("请输入正确的账户代码");
			return false;
		}
		var selGroupsVal = checkboxvalue("chk_group");
		var params = {
			memberId:selMemberId,
			relateCompanyid:$d("txtCompanyId").value,
			relateUserid:$d("txtUserId").value,
			relateName:$d("txtUsername").value,
			email:$d("txtEmail").value,
			telephone:$d("txtTelephone").value,
			remark:$d("txtRemark").value,
			selGroups:selGroupsVal
			};
		$.ajax({type: "POST",
		       url: "ajaxContact_saveMember.do",
		       data: params,
		       async: false,
		       success: function(result){
		         if(result.retcode=="0000"){
				  	alert(result.retmsg);
				  	loadContact();
				  	loadMember(selGroupId);
				 }else{
				  	alert(result.retmsg);
				 }
			  }
			},"json");
	}
   //for editMember end ====================================
   
   //====================other util func====================
   function fillListbox(listbox,memberList){
		listbox.length=0;
		for(var i=0;i<memberList.length;i++) {   
		   listbox.options[i] = new Option(memberList[i].relateUserid,memberList[i].id); 
		}
	}
		
	function move(fbox,tbox) { 
		for(var i=0; i<fbox.options.length; i++) { 
	       if(fbox.options[i].selected 
	       		&& fbox.options[i].value != "") { 
		     var no = new Option(); 
		     no.value = fbox.options[i].value; 
		     no.text = fbox.options[i].text; 
		     tbox.options[tbox.options.length] = no; 
		     fbox.options.remove(i); 
		     i--;
	       } 
	   }
   }
   
   // --列头全选框被单击---
	function ChkAllClick(sonName, cbAllId){
	    var arrSon = document.getElementsByName(sonName);
	 	var cbAll = document.getElementById(cbAllId);
	 	var tempState=cbAll.checked;
	 	for(i=0;i<arrSon.length;i++) {
	  	if(arrSon[i].checked!=tempState)
	        arrSon[i].click();
	 	}
	}
	
	// --子项复选框被单击---
	function ChkSonClick(sonName, cbAllId) {
	 	var arrSon = document.getElementsByName(sonName);
	 	var cbAll = document.getElementById(cbAllId);
	 	for(var i=0; i<arrSon.length; i++) {
	     	if(!arrSon[i].checked) {
	     		cbAll.checked = false;
	     		return;
	    	}
	 	}
	 	cbAll.checked = true;
	}
	
</script>
		<!-- script end -->
	</head>
	<body>
		<%@ include file="/user_top.jsp"%>
		<div class="realCer">
			<!--导航-->
			<!--主体部分start-->
			<div class="realMain clearfix mt10">
				<%@ include file="/user_menu.jsp"%>
				<div class="realRight ml10 Buyer">
					<div class="mybox">
						<div class="mytit">
							通讯录
						</div>
						<div class="con Orbuy">
							<form name="formpage">
								<input type="hidden" id="hdfCompanyId" value="${companyId }" />
								<input type="hidden" id="hdfUserId" value="${userId }" />
								<div class="pCenter">
									<!-- 
									<div class="at_tab_t">
									</div>
									 -->
									<div>
										<table>
											<tr>
												<td colspan="2">
													<div id="div_toolbar1"
														class="pagesMag mt10 clearfix newsPag"
														style="border-top: 1px solid #dfdfdf;">
														<p class="magtab">
															
															<span class="magspan ml5" style="width:150px">
															<!-- 快速搜索框  
															<input id="searchBox" name="searchBox" maxlength="20"
															size="20" type="text" />
															-->
															</span>
															
															<a id="a_editGroup" class="at_but b_2_g" href="#"
																onclick="editGroup();"> <u></u>编辑组 </a>
															<a id="a_deleteGroup" class="at_but b_2_g" href="#"
																onclick="delGroup();"> <u></u>删除组 </a>
															<a id="a_editMember" class="at_but b_2_g" href="#"
																onclick="editMember();"> <u></u>编辑联系人 </a>
															<a href="#" class="at_but b_2_g" onclick="addMember();">
																<u></u>新建联系人 </a>
															<a id="a_delMember" class="at_but b_2_g" href="#"
																onclick="delMember()"> <u></u>删除联系人 </a>
														</p>
													</div>
													<div id="div_goBack1" style="display: none;">
														<!-- 
														<a href="#" class="at_but b_2_g" onclick="goBack()"> <u></u>返回
														</a>
														 -->
													</div>
												</td>
											</tr>
											<tr>
												<td width="150" valign="top">
													<div style="border:1">
														<span id="spanGroups"> </span>
													</div>
													<br />
													<a href="#" onclick="addGroup();"> 新建组 </a>
												</td>
												<td width="700" valign="top">
													<!-- 联系人列表 start -->
													<div id="div_memberlist" style="display: block;">
														<table class="favorRwList mt5" id="tb_memberList">
														</table>
													</div>
													<!-- 联系人列表 end -->

													<!-- 新增/修改 联系组 start -->
													<div id="div_editgroup" style="display: none;">
														编辑组
														<div>
															组名：
															<input id="txtGroupName" type="text" maxlength="20"
																size="20" onblur="checkGroupName(this);" />
															<span id="groupNameError"></span>
														</div>
														<div>
															<table border="0" width="100%">
																<tr>
																	<td align="left" colspan="3">
																		可选联系人:
																	</td>
																</tr>
																<tr>
																	<td align="left">
																		<select id="myGroups" style="width: 160px">
																		</select>
																	</td>
																	<td width="100px">
																	</td>
																	<td align="left">
																		已选联系人(0)
																	</td>
																</tr>
																<tr>
																	<td>
																		<select multiple="multiple" size="13" id="list1"
																			style="width: 200px">
																		</select>
																	</td>
																	<td>
																		<input type="button" value="   >>   " id="btnAdd" />
																		<br />
																		<br />
																		<input type="button" value="   <<   " id="btnRemove" />
																	</td>
																	<td>
																		<select multiple="multiple" size="13" id="list2"
																			style="width: 200px">
																		</select>
																	</td>
																</tr>
															</table>

															<p>
																按住Ctrl键可以多选，shift键可选择范围，双击可以直接添加。
															</p>
															<p class="formAction">
																<input type="button" class="button" id="ok" name="ok"
																	value=" 保 存 " onclick="saveGroup();" />
																&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
																<input type="button" class="button" id="resets"
																	value=" 取 消 " onclick="goBack();" />
															</p>
														</div>
													</div>
													<!-- 新增/修改 联系组 end -->

													<!-- 新增/修改 联系人 start -->
													<div id="div_editmember" style="display: none;">
														<h2>
															<span class="l"></span>新建联系人
															<span class="r"></span>
														</h2>
														<table align="center" width="100%">
															<tr>
																<td align="right" width="120">
																	公司代码：
																</td>
																<td>
																	<input id="txtCompanyId" type="text" maxlength="20"
																		size="25" class="required" title="*必填"
																		onblur="showCompanyName(this);" />
																	<span id="companyIdError"></span>
																</td>
															</tr>

															<tr>
																<td align="right">
																	账户代码：
																</td>
																<td>
																	<input id="txtUserId" type="text" maxlength="20"
																		size="25" class="required" title="*必填"
																		onblur="checkUserId(this);" />
																	<span id="userIdError"></span>
																</td>
															</tr>

															<tr>
																<td align="right">
																	姓名：
																</td>
																<td>
																	<input id="txtUsername" type="text" maxlength="20"
																		size="25" />
																</td>
															</tr>
															<tr>
																<td align="right" width="120">
																	电子邮箱：
																</td>
																<td>
																	<input id="txtEmail" type="text" maxlength="50"
																		size="30" />
																</td>
															</tr>

															<tr>
																<td align="right">
																	电话：
																</td>
																<td>
																	<input id="txtTelephone" type="text" maxlength="20"
																		size="25" />
																</td>
															</tr>
															<tr>
																<td align="right">
																	备注：
																</td>
																<td>
																	<input id="txtRemark" type="text" maxlength="30"
																		size="25" />
																</td>
															</tr>

															<tr>
																<td align="right">
																	所属组：
																</td>
																<td>
																	<div id="div_groups"></div>
																</td>
															</tr>

															<tr>
																<td></td>
																<td>
																	<input type="button" class="button" id="ok" name="ok"
																		value=" 保 存 " onclick="saveMember();" />
																	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
																	<input type="button" class="button" id="resets"
																		value=" 取 消 " onclick="goBack();" />
																</td>
															</tr>
														</table>
													</div>
													<!-- 新增/修改 联系人 end -->

													<!-- 查看 联系人 start -->
													<div id="div_viewmember" style="display: none;">
														查看联系人
														<table align="center" width="100%">
															<tr>
																<td align="right" width="120">
																	公司代码：
																</td>
																<td>
																	<span id="spanCompanyId" />
																</td>
															</tr>
															<tr>
																<td align="right" width="120">
																	公司名称：
																</td>
																<td>
																	<span id="spanCompanyName" />
																</td>
															</tr>
															<tr>
																<td align="right">
																	账户代码：
																</td>
																<td>
																	<span id="spanUserid" />
																</td>
															</tr>

															<tr>
																<td align="right">
																	姓名：
																</td>
																<td>
																	<span id="spanUsername" />
																</td>
															</tr>
															<tr>
																<td align="right" width="120">
																	电子邮箱：
																</td>
																<td>
																	<span id="spanEmail" />
																</td>
															</tr>

															<tr>
																<td align="right">
																	电话：
																</td>
																<td>
																	<span id="spanTelephone" />
																</td>
															</tr>
															<tr id="tr_memberInfo2">
																<td align="right">
																	备注：
																</td>
																<td>
																	<span id="spanRemark" />
																</td>
															</tr>

															<tr id="tr_memberInfo3">
																<td align="right">
																	所属组：
																</td>
																<td>
																	<span id="spanInGroups" />
																</td>
															</tr>
														</table>
													</div>
													<!-- 查看 联系人 end -->

												</td>
											</tr>
											<tr>
												<td width="150"></td>
												<td>
													<div id="div_toolbar2">
														button toolbar
													</div>

													<div id="div_goBack2" style="display: none;">
														<a href="#" onclick="goBack()"> 返回 </a>
													</div>
												</td>
											</tr>
										</table>
									</div>
								</div>
							</form>
						</div>
					</div>
					<div>
					</div>
					<!--主体部分end-->
				</div>
			</div>
		</div>
		<!--底部 start-->
		<%@ include file="/user_button.jsp"%>
		<!--底部end-->
	</body>
</html>
